using System;

using Sunyi.Project.WebPoint.Common;
using Sunyi.Project.WebPoint.DataAccessController;

using Sunyi.Project.WebPoint.DataAccess;
using Sunyi.Project.WebPoint.DataContract;

namespace Sunyi.Project.WebPoint.DataAccessController
{
    public partial class IssueDaoController : BaseDaoController<Issue, IssueDao>
    {
        public override void Insert(Issue issue)
        {
            if (issue.Id == Guid.Empty) issue.Id = Guid.NewGuid();

            TransactionHelper.ProcessTransaction(() => { dao.Insert(issue); dao.SaveAttachments(issue); });
        }

        public void Save(Issue issue)
        {
            TransactionHelper.ProcessTransaction(() => { dao.Update(issue); dao.SaveAttachments(issue); });
        }

        protected override void FillEntity(Issue entity) { if (entity != null) { dao.FillAttachments(entity); } }
    }
}
